package com.lf.freezingpoint.controller;

import com.lf.freezingpoint.common.entity.R;
import com.lf.freezingpoint.entity.SysUser;
import com.lf.freezingpoint.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.logging.Logger;

@RestController
@Tag(name = "用户管理",description = "用户管理接口文档")
@RequestMapping("/api/user")
public class UserController {
    private static final Logger logger = Logger.getLogger(UserController.class.toString());

    @Autowired
    private SysUserService sysUserService;

    @Operation(summary = "根据用户名查询用户信息")
    @GetMapping("/getUserInfo")
    public R getUserInfo(@RequestBody SysUser sysUser) {
        String username = sysUser.getUsername();
        SysUser sysUser1 = sysUserService.getSysUserInfoByUsername(username);
        /*List<String> roles = new ArrayList<>();
        sysUser.getRoles().forEach(role -> roles.add(role.getRoleKey()));*/

        return R.ok(sysUser1, "获取成功");
    }

}
